
package cn.trda.base.iothreadsocker;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
class MyTread extends Thread{
	private Socket s;
	public MyTread(Socket s){
		this.s=s;
	}
	
	@Override
	public void run() {
		//s.getInputStream();
		try{
		FileInputStream fis=new FileInputStream(new File("d:/a.html"));
		OutputStream os=	s.getOutputStream();
		int len=-1;
		byte [] b=new byte[1024];
		while((len=fis.read(b))!=-1){
			os.write(b,0,b.length);
			os.flush();
		}
		os.close();
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
	
}

public class MyWeb {

		public static void main(String[] args) throws Exception {
			
			//create server	
			ServerSocket ss=new ServerSocket(6666);
			
			while(true){
				//reserice client message
				Socket s=	ss.accept();
				new MyTread(s).start();
			
			}
			
			
			
			
			
		}
	
}
